<template>
	<view class="container-nav">
		<view class="w-nav">
			<view class="nav-title" @click="onClkTitle(0)">
				<text :class="{'nav-focus':active==0}">我发出的</text>
			</view>
			<view class="nav-title" @click="onClkTitle(1)">
				<text :class="{'nav-focus':active==1}">我的团队</text>
			</view>
		</view>
		<view class="nav-tip" v-show="blnShowTip">
			<view>
				{{start_Date}} 年 {{start_Month}} 月报
			</view>
			<view class="cls" @click="onClsSearch"></view>
		</view>
		<view class="nav-body" v-show="active==0">
			<view class="w-box" v-for="(item,index) in items_a" :key="index" @click="onNavTo(item.ID)">
				<view class="w-box-title">
					<view class="w-box-title-img">{{_retSlgName(item.Reporter)}}</view>
					<view>
						<view class="w-box-title-header">
							{{item.Reporter}}的月报
						</view>
						<view class="w-box-title-dt">
							{{item.ReportYear}} 年 {{item.ReportMonth}} 月
						</view>
					</view>
					<view class="w-box-title-org">
						{{item.OrgID}}
					</view>
				</view>
				<view class="w-box-row">
					<text>本月总结: {{item.Summary}}</text>
				</view>
				<view class="w-box-row">
					<text>下月计划: {{item.Plan}}</text>
				</view>
			</view>
		</view>
		<view class="nav-body" v-show="active==1">
			<view class="w-box" v-for="(item,index) in items_b" :key="index" @click="onNavTo(item.ID)">
				<view class="w-box-title">
					<view class="w-box-title-img">{{_retSlgName(item.Reporter)}}</view>
					<view>
						<view class="w-box-title-header">
							{{item.Reporter}}的月报
						</view>
						<view class="w-box-title-dt">
							{{item.ReportYear}} 年 {{item.ReportMonth}} 月
						</view>
					</view>
					<view class="w-box-title-org">
						{{item.OrgID}}
					</view>
				</view>
				<view class="w-box-row">
					<text>本月总结: {{item.Summary}}</text>
				</view>
				<view class="w-box-row">
					<text>下月计划: {{item.Plan}}</text>
				</view>
			</view>
		</view>
		<uni-fab :pattern="pattern" :content="content" :horizontal="horizontal" :vertical="vertical" :direction="direction"
		 @trigger="trigger"></uni-fab>
	</view>
</template>

<script>
	let pageApp = getApp();
	export default {
		data() {
			return {
				items_a: [],
				items_b: [],
				start_Date: "请选择",
				start_Month: "请选择",
				blnShowTip: false,
				active: 0,
				title: 'uni-fab',
				directionStr: '垂直',
				horizontal: 'left',
				vertical: 'bottom',
				direction: 'horizontal',
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#4497e1',
					buttonColor: '#4497e1'
				},
				content: [{
						iconPath: '/static/images/navIcon/icon-6.png',
						selectedIconPath: '/static/images/navIcon/icon-6-focus.png',
						text: '看月报',
						active: true
					},
					{
						iconPath: '/static/images/navIcon/icon-7.png',
						selectedIconPath: '/static/images/navIcon/icon-7-focus.png',
						text: '写月报',
						active: false
					},
					{
						iconPath: '/static/images/navIcon/icon-8.png',
						selectedIconPath: '/static/images/navIcon/icon-8-focus.png',
						text: '查询',
						active: false
					}
				]
			}
		},
		methods: {
			onClkTitle(e) {
				this.active = e;
			},
			_retSlgName(v) {
				return (v) ? v.substr(0, 1) : "";
			},
			onClsSearch(e) {
				uni.navigateBack();
			},
			onNavTo(ID) {
				uni.navigateTo({
					url: "./MonthlyRepInfo?id=" + ID
				})
			},
			trigger(e) {
				switch (e.index) {
					case 0:
						uni.navigateTo({
							url: "./MonthlyRepList"
						});
						break;
					case 1:
						uni.navigateTo({
							url: "./MonthlyRepEdit"
						});
						break;
					case 2:
						uni.navigateTo({
							url: "./MonthlyRepFilter"
						});
						break
				}
			}
		},
		onLoad: function(options) {
			this.start_Date = options.start_Date;
			this.start_Month = options.start_Month;
			if (this.start_Date && this.start_Month) {
				this.blnShowTip = true;
				// 准备请求数据
				let apiData = {
					url: pageApp.globalData.url + "/MonthlyReportList",
					data: {
						"page": 1,
						"rows": 10,
						"ReportYear": this.start_Date,
						"ReportMonth": this.start_Month
					},
					success: (d) => {
						this.items_a = d.data.data.items;
					}
				}
				// 发送数据请求
				this.vjAjaxData(apiData);
			} else {
				// 准备请求数据
				let apiData_a = {
					url: pageApp.globalData.url + "/MonthlyReportList",
					data: {
						"page": 1,
						"rows": 10,
						"DataRange": "my"
					},
					success: (d) => {
						uni.hideLoading();
						this.items_a = d.data.data.items;
					}
				}
				// 发送数据请求
				this.vjAjaxData(apiData_a);
				// 准备请求数据
				let apiData_b = {
					url: pageApp.globalData.url + "/MonthlyReportList",
					data: {
						"page": 1,
						"rows": 10,
						"DataRange": "currentDepartment"
					},
					success: (d) => {
						this.items_b = d.data.data.items;
					}
				}
				// 发送数据请求
				this.vjAjaxData(apiData_b);
			}
		}
	}
</script>

<style>
	page {
		background-color: #F1F5F6;
	}

	.container-nav {
		font-size: 14px;
		line-height: 24px;
	}

	.w-nav {
		display: flex;
		justify-content: space-between;
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
		padding: 20rpx 0;
	}

	.nav-focus {
		border-bottom: solid 6rpx #4497e1;
		padding-bottom: 20rpx;
	}

	.nav-title {
		width: 50%;
		text-align: center;
	}

	.nav-tip {
		position: relative;
		padding: 10rpx;
		display: flex;
		width: 100%;
		top: -30rpx;
		background-color: #4497e1;
		color: #ffffff;
		font-size: 26rpx;
		justify-content: space-around;
	}

	.nav-body {
		background-color: #FFFFFF;
		padding: 0 40rpx;
	}

	.w-box {
		padding: 40rpx 0;
		border-bottom: solid 2rpx #F1F5F6;
	}

	.w-box-title {
		display: flex;
		margin-bottom: 40rpx;
	}

	.w-box-title-img {
		width: 60rpx;
		height: 60rpx;
		padding: 4rpx;
		text-align: center;
		line-height: 60rpx;
		border-radius: 50%;
		background-color: #4497e1;
		margin-right: 16rpx;
		margin-top: 15rpx;
		color: #ffffff;
		font-size: 30rpx;
	}

	.w-box-title-header {
		font-size: 34rpx;
		color: #000000;
		font-weight: 700;
	}

	.w-box-title-dt {
		font-size: 26rpx;
		line-height: 30rpx;
	}

	.w-box-title-org {
		position: absolute;
		margin-top: 16rpx;
		right: 40rpx;
	}
	.w-box-row{
		font-size: 30rpx;
		line-height: 36rpx;
	}
	.w-box-row text {
		overflow: hidden;
		display: inline-block;
		text-overflow: ellipsis;
		white-space: nowrap;
		width: 670rpx;
	}
</style>
